<link rel="stylesheet" type="text/css" href="assets/bootstrap-datepicker/css/datepicker.css" />
<aside class="lg-side">
  <div class="panel-heading tab-bg-dark-navy-blue okr-tab-head tab-right "></div>
  <div class="inbox-body mi-h8">
    <div class="row">
      <div class="col-lg-12">
        <div class="alert alert-block alert-danger fade in">
          <button data-dismiss="alert" class="close close-sm" type="button">
            <i class="icon-remove"></i>
          </button>
          <strong>友情提示：</strong>
          请根据实际情况填写
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-lg-12">
        <form>
          <section class="panel">
            <header class="panel-heading">
              本周投标、收入和下周预测情况
            </header>
            <div class="panel-body">

              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">填写周期*</label>
                <div class="col-sm-10">

                  <div class="col-lg-6" style="padding-left:0;">
                    <input id="beginTime" name="beginTime" type="text" value="" class="form-control" placeholder="开始日期"
                      onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');">
                  </div>
                  <div class="col-lg-6" style="padding-right:0;">
                    <input id="endTime" name="endTime" type="text" value="" autocomplete="off" class="form-control"
                      placeholder="结束日期" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');">
                  </div>

                </div>
              </div>

              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">本阶段投标总金额*</label>
                <div class="col-sm-10">
                  <div class="input-group m-bot15">
                    <span class="input-group-addon">￥</span>
                    <input id="nowBiddingTime" name="nowBiddingTime" type="text" value="" autocomplete="off"
                      class="form-control" onkeyup="clearNoNum(this)" onblur="clearNoNum(this)" min="0"
                      onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');">
                    <span class="input-group-addon">元</span>
                  </div>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">本阶段投标说明</label>
                <div class="col-sm-10">
                  <textarea class="form-control" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');" id="nowBiddingComments"
                    name="nowBiddingComments" placeholder="字数限制(120字以内)" maxlength="120"></textarea>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">本阶段中标总金额*</label>
                <div class="col-sm-10">
                  <div class="input-group m-bot15">
                    <span class="input-group-addon">￥</span>
                    <input id="nowGetTime" onkeyup="clearNoNum(this)" onblur="clearNoNum(this)" min="0"
                      onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');" name="nowGetTime" type="text" value="" autocomplete="off"
                      class="form-control">
                    <span class="input-group-addon">元</span>
                  </div>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">本阶段中标说明</label>
                <div class="col-sm-10">
                  <textarea class="form-control" id="nowGetComments" name="nowGetComments" placeholder="字数限制(120字以内)"
                    maxlength="120" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');"></textarea>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">本阶段流标总金额*</label>
                <div class="col-sm-10">
                  <div class="input-group m-bot15">
                    <span class="input-group-addon">￥</span>
                    <input id="nowLoseTime" name="nowLoseTime" type="text" value="" autocomplete="off"
                      class="form-control" onkeyup="clearNoNum(this)" onblur="clearNoNum(this)" min="0"
                      onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');">
                    <span class="input-group-addon">元</span>
                  </div>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">本阶段流标说明</label>
                <div class="col-sm-10">
                  <textarea class="form-control" id="nowLoseComments" name="nowLoseComments" placeholder="字数限制(120字以内)"
                    maxlength="120" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');"></textarea>
                </div>
              </div>
              <div class="form-group customerForm" id="fxsmoney">
                <label class="col-sm-2 control-label">本阶段非销售总金额*</label>
                <div class="col-sm-10">
                  <div class="input-group m-bot15">
                    <span class="input-group-addon">￥</span>
                    <input id="nowIncome" name="nowIncome" type="text" value="" autocomplete="off" class="form-control"
                      onkeyup="clearNoNum(this)" onblur="clearNoNum(this)" min="0"
                      onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');">
                    <span class="input-group-addon">元</span>
                  </div>
                </div>
              </div>
              <div class="form-group customerForm" id="fxsdesc">
                <label class="col-sm-2 control-label">本阶段非销售说明</label>
                <div class="col-sm-10">
                  <textarea class="form-control" id="nowIncomeComments" name="nowIncomeComments"
                    placeholder="字数限制(120字以内)" maxlength="120" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');"></textarea>
                </div>
              </div>
              <div class="box-hr"><span>下周预测</span></div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">下周合同总金额*</label>
                <div class="col-sm-10">
                  <div class="input-group m-bot15">
                    <span class="input-group-addon">￥</span>
                    <input name="nextContractMoney" id="nextContractMoney" type="text" value="" autocomplete="off"
                      class="form-control" onkeyup="clearNoNum(this)" onblur="clearNoNum(this)" min="0"
                      onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');">
                    <span class="input-group-addon">元</span>
                  </div>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">下周合同说明</label>
                <div class="col-sm-10">
                  <textarea class="form-control" id="nextContractComments" name="nextContractComments"
                    placeholder="字数限制(120字以内)" maxlength="120" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');"></textarea>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">下周开票总金额*</label>
                <div class="col-sm-10">
                  <div class="input-group m-bot15">
                    <span class="input-group-addon">￥</span>
                    <input name="nextInvoice" id="nextInvoice" type="text" value="" autocomplete="off"
                      class="form-control" onkeyup="clearNoNum(this)" onblur="clearNoNum(this)" min="0"
                      onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');">
                    <span class="input-group-addon">元</span>
                  </div>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">下周开票说明</label>
                <div class="col-sm-10">
                  <textarea class="form-control" id="nextInvoiceComments" name="nextInvoiceComments"
                    placeholder="字数限制(120字以内)" maxlength="120" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');"></textarea>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">下周回款总金额*</label>
                <div class="col-sm-10">
                  <div class="input-group m-bot15">
                    <span class="input-group-addon">￥</span>
                    <input name="nextRefoundMoney" id="nextRefoundMoney" type="text" value="" autocomplete="off"
                      class="form-control" onkeyup="clearNoNum(this)" onblur="clearNoNum(this)" min="0"
                      onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');">
                    <span class="input-group-addon">元</span>
                  </div>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">下周回款说明</label>
                <div class="col-sm-10">
                  <textarea class="form-control" id="nextRefoundComments" name="nextRefoundComments"
                    placeholder="字数限制(120字以内)" maxlength="120" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');"></textarea>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">下周投标说明</label>
                <div class="col-sm-10">
                  <textarea class="form-control" id="nextBiddingComments" name="nextBiddingComments"
                    placeholder="字数限制(120字以内)" maxlength="120" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');"></textarea>
                </div>
              </div>
              <p class="default-buttons">
                <a href="javascript:void(0);" class="button-back btn btn-info" onclick="toBack()">返回</a>
                <a href="javascript:void(0);" class="button-next  btn btn-info submit">提交</a>
              </p>
            </div>
          </section>
        </form>
      </div>
    </div>
  </div>
</aside>
<script type="text/javascript" src="assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script>
  if (proBaseInfo.proType == "XS") {
    $("#fxsmoney").hide();
    $("#fxsdesc").hide();
  }

  $('#beginTime').datepicker({
    format: 'yyyy-mm-dd'
  });
  $('#endTime').datepicker({
    format: 'yyyy-mm-dd'
  });
  function edittbyc(id) {
    $certusUtils.ajax('findRpbidinof', { "id": id }, function (response) {
      var data = response.data;
      $("#nowBiddingTime").val(data.nowBiddingTime);
      $("#nowBiddingComments").val(data.nowBiddingComments);
      $("#nowGetTime").val(data.nowGetTime);
      $("#nowGetComments").val(data.nowGetComments);
      $("#nowLoseTime").val(data.nowLoseTime);
      $("#nowLoseComments").val(data.nowLoseComments);
      $("#nowIncome").val(data.nowIncome);
      $("#nowIncomeComments").val(data.nowIncomeComments);
      // $("#nowCustomerComplain").val(data.nowCustomerComplain);
      // $("#nowCustomerRequest").val(data.nowCustomerRequest);
      $("#nextContractMoney").val(data.nextContractMoney);
      $("#nextContractComments").val(data.nextContractComments);
      $("#nextInvoice").val(data.nextInvoice);
      $("#nextInvoiceComments").val(data.nextInvoiceComments);
      $("#nextRefoundMoney").val(data.nextRefoundMoney);
      $("#nextRefoundComments").val(data.nextRefoundComments);
      $("#nextBiddingComments").val(data.nextBiddingComments);

      $("#beginTime").val($.fn.dlshouwen.grid.tools.dateFormat(new Date(data.beginTime), "yyyy-MM-dd"));
      $("#endTime").val($.fn.dlshouwen.grid.tools.dateFormat(new Date(data.endTime), "yyyy-MM-dd"));
    });

    $(".submit").on('click', function () {

      var datetime = $("#beginTime").val();
      var endTime = $("#endTime").val();

      if (datetime == "" || datetime == null || datetime == undefined) {
        layer.msg("开始日期不能为空！");
        return;
      }

      if (endTime == "" || endTime == null || endTime == undefined) {
        layer.msg("结束日期不能为空！");
        return;
      }

      var start = new Date(datetime.replace("/", "-").replace("/", "-"));
      var finish = new Date(endTime.replace("/", "-").replace("/", "-"));
      if (start > finish) {
        layer.msg("开始日期不能大于结束日期");
        return;
      }

      var money = [];

      money.push($("#nowBiddingTime").val());
      money.push($("#nowGetTime").val());
      money.push($("#nowLoseTime").val());
      money.push($("#nextContractMoney").val());
      money.push($("#nextInvoice").val());
      money.push($("#nextRefoundMoney").val());

      // console.log(money);

      var sumMoney = '';

      for (var j = 0; j < money.length; j++) {
        sumMoney += money[j];
      }

      if (sumMoney === "000000") {
        layer.msg("请至少填写一项实际收入或预测数据！");
        return;
      }


      var arr = $("form").serializeArray();
      var data = {};
      for (var i = 0; i < arr.length; i++) {
        data[arr[i].name] = arr[i].value;
      };
      data.proId = proId;
      data.id = id;
      data.beginTime = datetime;
      $certusUtils.ajax("toEditBid", {
        "param": JSON.stringify(data)
      }, function () {
        layer.msg("修改成功", {
          "time": 1000
        });
        toLoadHtml(4, 2);
      });
    });
  }

  function toBack() {
    toLoadHtml(4, 2);
  }
</script>